package br.com.sgi.autentication;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import br.com.sgi.util.Mensagem;

@Controller("loginBean")
@Scope("request")
public class LoginBean {

	 @Autowired
	  private AuthenticationService authenticationService;

	  private String userName;
	  private String password;

	  public String login() {
	    boolean success = authenticationService.login(userName, password);

	    if (!success) {
	    Mensagem.msg("erro.MSG_03", "j_spring_security_check:login");
	    
	      
	      return null;
	    }

	    return "home";
	  }

	  public String logout() {
	    authenticationService.logout();
	    return "login";
	  }

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}
	  
	  
}
